﻿@page "/Polar/Basic"
@using LiveChartsCore.SkiaSharpView.Blazor
@using LiveChartsCore.SkiaSharpView
@using LiveChartsCore
@using LiveChartsCore.SkiaSharpView.Painting
@using LiveChartsCore.SkiaSharpView.VisualElements
@using LiveChartsCore.SkiaSharpView.Drawing.Geometries
@using SkiaSharp

<PolarChart
	Series="Series"
    RadiusAxes="RadiusAxes"
    AngleAxes="AngleAxes"
    Title="Title">
</PolarChart>

@code {
    private ISeries[] Series { get; set; }
    private PolarAxis[] RadiusAxes { get; set; }
    private PolarAxis[] AngleAxes { get; set; }
    private DrawnLabelVisual Title { get; set; }

    protected override void OnInitialized()
    {
        var values = new double[] { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
        var cotangentAngle = LiveCharts.CotangentAngle;
        var tangentAngle = LiveCharts.TangentAngle;

        Series = new ISeries[]
        {
            new PolarLineSeries<double>
            {
                Values = values,
                ShowDataLabels = true,
                GeometrySize = 15,
                DataLabelsSize = 8,
                DataLabelsPosition = LiveChartsCore.Measure.PolarLabelsPosition.Middle,
                DataLabelsRotation = cotangentAngle,
                IsClosed = true
            }
        };

        RadiusAxes = new PolarAxis[]
        {
            new() {
                LabelsAngle = -60,
                MaxLimit = 30
            }
        };

        AngleAxes = new PolarAxis[]
        {
            new() {
                LabelsRotation = tangentAngle
            }
        };

        Title = new DrawnLabelVisual(
            new LabelGeometry
            {
                Text = "My chart title",
                Paint = new SolidColorPaint(SKColor.Parse("#303030")),
                TextSize = 25,
                Padding = new LiveChartsCore.Drawing.Padding(15)
            });
    }
}
